﻿using System;
using System.Collections.Generic;
using System.Text;

namespace X3DLib
{
    public class ScriptContent
    {
        /// <summary>
        /// Script脚本函数体注释头
        /// </summary>
        /// <returns></returns>
        public string contextHead (){return  "<![CDATA[\njavascript:\n";}
        /// <summary>
        /// 初始化控制系统
        /// </summary>
        /// <param name="init"></param>
        /// <returns></returns>
        public string initialize(string initialize)
        {
            return "function initialize()\n"
                    + "{\n"
                        + (initialize==""?("init_environment();\n"
                                            +"init_particles();\n"):initialize)
                    + "}\n";
        }
        public string init_environment(string environment)
        {
            return "function init_environment()\n"
                    + "{\n"
                        + environment
                    + "}\n";
        }
        /// <summary>
        /// 初始化粒子
        /// </summary>
        /// <param name="init_part"></param>
        /// <returns></returns>
        public string init_particles(string init_part)
        {
            return "function init_particles()\n"
                    + "{\n"
                        + init_part
                    + "}\n";
        }
        /// <summary>
        /// 实时更新各粒子状态
        /// </summary>
        /// <param name="update_part"></param>
        /// <returns></returns>
        public string update_particles(string update_part)
        {
            return "function update_particles()\n"
                    + "{\n"
                        + update_part
                    + "}\n";
        }
        /// <summary>
        /// 实时更新粒子系统状态
        /// </summary>
        /// <param name="update"></param>
        /// <returns></returns>
        public string update(string update)
        {
            return "function update()\n"
                    + "{\n"
                    + (update ==""?"update_particles();\n":update)
                    + "}\n";
        }
        /// <summary>
        /// 启动函数
        /// </summary>
        /// <param name="start"></param>
        /// <returns></returns>
        public string start(string start)
        {
            return "function start(vale)\n"
                + "{\n"
                + (start==""?"update();\n":start)
                + "}\n";
        }
        /// <summary>
        /// 触碰响应函数
        /// </summary>
        /// <param name="touch_change"></param>
        /// <returns></returns>
        public string touch_change(string touch_change)
        {
            return "function touch_change(value)\n"
                    + "{\n"
                        + touch_change
                    + "}\n";
        }
        /// <summary>
        /// Script脚本函数体注释尾
        /// </summary>
        /// <returns></returns>
        public string contextEnd (){return  "\n]]>\n";}
    }
}
